<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/view/include/css-include.jsp"%>
<%@ include file="/view/include/jsp-include.jsp"%>
<%@ include file="/view/include/jquery-include.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Return Cause</title>

<script type="text/javascript">

    $().ready(function() {
        /* 달력 */
        $( "#date" ).datepicker({
            showOn: "button",
            buttonImage: "/images/calendar.gif",
            buttonImageOnly: true
        });
        
        $("#reSetBtn").bind("click",function(){
            $("form[name='returncauseWriteFrm']").each(function(){
                  this.reset();
            });
            
        });

        $("#onList").bind("click",function(){
             location="/returncause.html";            
        });

        /* 저장버튼 */
        $("#saveBtn").bind("click",function(){       
            $("form[name='returncauseWriteFrm']").submit();
        });

        /* 메인폼 서브밋 */
        $("form[name='returncauseWriteFrm']").ajaxForm({
            dataType: "json",
            beforeSerialize: function($form, options) {
                //return $("form[name='orderFrm']").valid();  jquery 벨류데이션 플러그인 사용시
                 if( !validation() ){       //화면 항목 점검 시작
                    return false;
                }
            },
            success:function(data) {
               if(data.result == true){
                   alert("Saved.....!");
                   location="/returncause.html";    
               }               
           },
           error:function(){alert("ERROR!");}
        }); 
    });

    function validation(){

        //var returnCode    = $("#returnCode").val();
        var returnName    = $("#returnName").val();
        
        //if(returnCode==null     || returnCode=="") {   alert("Return Cause Code required!!"); $("#returnCode").focus(); return false; }
        if(returnName==null    || returnName=="") { alert("Return Cause Name required!!"); $("#returnName").focus(); return false; }
   
      return true;      
    } 
    
</script>
</head>
<body>
<div class="wrap">
    <form name="returncauseWriteFrm" method="post" action="/saveReturncause.json">
    <div class="pagetitle">
        <h1>RETURN CAUSE / INSERT</h1>
    </div>
    <div>
        <table class="TableST">
            <tr>
                <th>Return Cause</th>
                <td>
                    <input type="text" class="inSTR" size="80" name="returnCode" id="returnCode" readonly/>
                </td>
            </tr>
            <tr>
                <th>Name</th>
                <td><input type="text" class="inST" size="80" name="returnName" id="returnName"/></td>
            </tr>            
         </table>
    </div>
    <div class="bo_btn">        
        <ul class="btnst"><li class="a"><a href="#" id="reSetBtn" >INIT</a></li></ul>
        <ul class="btnst"><li class="a"><a href="#" id="onList" >LIST</a></li></ul>
        <ul class="btnst"><li class="a"><a href="#" id="saveBtn" >SAVE</a></li></ul>      
    </div>
    <input type="hidden" name="saveStatus" id="saveStatus" value="SAVE"/>
    </form>
</div>
</body>
</html>